package algorithm.swordoff;

import java.util.HashSet;
import java.util.Set;


/**
 * 数组中重复的数字
 */

public class SQ03 {

    public int findRepeatNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            if (set.contains(num)) return num;
            else set.add(num);
        }
        return -1;
    }

}
